//
//  PADataCenter.m
//  PAMobileWallet
//
//  Created by Gavin Zhang on 7/16/13.
//  Copyright (c) 2013 平安付. All rights reserved.
//

#import "PADataCenter.h"
#import "PANetworkManager.h"
#import "PAUserInfo.h"
#import "PABankCardInfo.h"
#import "PATimeLineInfo.h"
static PADataCenter *_sharedInstance;

@implementation PADataCenter
@synthesize selfInfo;
#pragma mark - singleTon implementation
+ (PADataCenter *)sharedInstance
{
    if (!_sharedInstance) {
        _sharedInstance = [[super allocWithZone:NULL] init];
        _sharedInstance.selfInfo = [[PASelfInfo alloc] init];
    }
    return _sharedInstance;
}
+(id)allocWithZone:(NSZone *)zone
{
    return [PADataCenter sharedInstance];
}
-(id)copyWithZone:(NSZone *)zone
{
    return self;
}

/*
 *  1.刷新内存使用数据
 *  2.刷新本地缓存数据
 */
- (void)updateLoginInfoDic:(NSDictionary *)dic
{
    [self.selfInfo loadLoginInfoDic:dic];
    [self.selfInfo loadFromCache];
}
- (void)updateTimeLineInfoDic:(NSDictionary *)dic
{
    NSArray *timeLineInfos = [dic objectForKey:k_timeLineInfos];
    [self.selfInfo updateTimeLineInfoDics:timeLineInfos];
    [self.selfInfo updateTimeLineInfoCacheDics:timeLineInfos];
}
- (void)updateBankCardInfo:(NSDictionary *)dic
{
    NSArray *bankCardInfoDics = [dic objectForKey:k_bankCardInfos];
    [self.selfInfo updateBankCardInfoDics:bankCardInfoDics];
    [self.selfInfo updateBankCardInfoCacheDics:bankCardInfoDics];
}

- (void)loadCacheForLoginId:(NSString *)loginId
{
    [self.selfInfo loadFromCache];
}
@end
